<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFileUserEditErrorTable extends Migration
{
    /**
     * 数据表名称
     * @var string
     */
    private $tableName = 'file_user_edit_error';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 创建数据表
        Schema::create($this->tableName, function (Blueprint $table) {
            // 数据表类型
            $table->engine = 'InnoDB';
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';

            // 数据表字段
            $table->id('id')->comment('递增主键');
            $table->bigInteger('file_id', false, true)->comment('文件主键');
            $table->integer('index', false, true)->comment('行号');
            $table->string('error', 200)->comment('错误消息');
            $table->timestamp('created_at')->comment('数据创建时间')->default(DB::raw('CURRENT_TIMESTAMP'));

            // 数据表索引
            $table->index('file_id');
        });
        // 设置数据表备注信息
        DB::statement("ALTER TABLE `".env('DB_PREFIX')."{$this->tableName}` COMMENT'用户修改导入错误表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
